//
// Created by amir on 21.03.24.
//

#include "Timer.h"

Timer::Timer(double time) {
    start_time = time;
    past_time = 0;
    isRunTime = true;
}

void Timer::setTime(double time) {
    start_time = time;
}

void Timer::reset() {
    past_time = 0;
}

void Timer::start() {
    isRunTime = true;
}

void Timer::stop() {
    isRunTime = false;
}

void Timer::update() {
    if(!isRunTime)
        return;
    past_time += (past_time > start_time) ? Time::dt() : 0;
}

double Timer::get_time() {
    return start_time - past_time;
}
